package com.party.core.service.school.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.school.ScClassReadDao;
import com.party.core.dao.write.school.ScClassWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.school.ScClass;
import com.party.core.service.school.IScClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Service
public class ScClassService implements IScClassService {
    @Autowired
    private ScClassReadDao classReadDao;

    @Autowired
    private ScClassWriteDao classWriteDao;

    @Override
    public String insert(ScClass scClass) {
        BaseModel.preInsert(scClass);
        if (classWriteDao.insert(scClass)) {
            return scClass.getId();
        }
        return null;
    }

    @Override
    public boolean update(ScClass scClass) {
        scClass.setUpdateDate(new Date());
        return classWriteDao.update(scClass);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return false;
        }
        return classWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public ScClass get(String id) {
        if (Strings.isNullOrEmpty(id)) {
            return null;
        }
        return classReadDao.get(id);
    }

    @Override
    public List<ScClass> listPage(ScClass scClass, Page page) {
        return classReadDao.listPage(scClass, page);
    }

    @Override
    public List<ScClass> list(ScClass scClass) {
        return classReadDao.listPage(scClass, null);
    }

    @Override
    public List<ScClass> batchList(Set<String> ids, ScClass scClass, Page page) {
        return null;
    }
}
